package com.dgshanger.sanhxiaofeisc.mvp.presenter

import com.dgshanger.sanhxiaofeisc.entity.ShopGoodsItemEntity
import com.dgshanger.sanhxiaofeisc.mvp.contract.ShopGoodsListContract
import com.dgshanger.sanhxiaofeisc.mvp.model.ShopGoodsListModel
import com.xx.baseuilibrary.mvp.BaseMvpPresenter
import com.xx.baseutilslibrary.network.rx.XxBaseHttpObserver

/**
 * Created by JacobHHH on 2018/4/20.
 */
class ShopGoodsListPresenter : BaseMvpPresenter<ShopGoodsListContract.Model, ShopGoodsListContract.View>(), ShopGoodsListContract.Presenter {


    override fun loadData(shop_id: String?, page: String?, isLoadMore : Boolean) {

        getModel().loadData(shop_id,page,object  : XxBaseHttpObserver<List<ShopGoodsItemEntity>>(){

            override fun onCompleted(msg: String?, entity: List<ShopGoodsItemEntity>?) {
                getView()?.setData(entity,isLoadMore)
            }

            override fun onError(error: String?) {
                getView()?.showToast(error)
                getView()?.onDataFailure(error)
            }

            override fun onStart() {

            }

            override fun onFinish() {

            }

        })
    }

    override fun createModel(): ShopGoodsListContract.Model = ShopGoodsListModel()
}